<?php
/* -----------------------------------------------------------------------------------------
   $Id: xtc_get_attributes_model.inc.php,v 1.1 2010/09/08 10:55:03 akausch Exp $   

   XT-Commerce - community made shopping
   http://www.xt-commerce.com

   Copyright (c) 2003 XT-Commerce
   -----------------------------------------------------------------------------------------
   based on:
   (c) 2003	 nextcommerce (xtc_get_attributes_model.inc.php,v 1.1 2003/08/19); www.nextcommerce.org
   
   Released under the GNU General Public License
   ---------------------------------------------------------------------------------------*/
   
function xtc_get_attributes_model($product_id, $attribute_name) {

    $options_value_id_query = xtDBquery("SELECT
                products_options_values_id
                FROM ".TABLE_PRODUCTS_OPTIONS_VALUES."
                WHERE products_options_values_name='".$attribute_name."'");

    while ($options_value_id_data = xtc_db_fetch_array($options_value_id_query)) {
	    $options_attr_query = xtDBquery("SELECT
	                attributes_model
	                FROM ".TABLE_PRODUCTS_ATTRIBUTES."
	                WHERE options_values_id='".$options_value_id_data['products_options_values_id']."' AND products_id =" . $product_id);
	    $options_attr_data = xtc_db_fetch_array($options_attr_query);
	    if ($options_attr_data['attributes_model']!='')
	    	return $options_attr_data['attributes_model'];
    }
}
?>